import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import LoadingComp from '@/components/LoadingComp'
import ErrorComp from '@/components/ErrorComp'
import vuexpage from '@/components/vuexpage'

//购物车
import product from '@/components/product'


console.log(ErrorComp,'111111111111111111111111111111111111111')
const y =  import('@/components/h1.vue')
console.log(y,'11111111111111111111111111222222')
const AsyncComp = () => ({
  // 需要加载的组件。应当是一个 Promise
  component:import('@/components/h1.vue'),
  // 加载中应当渲染的组件
  loading: LoadingComp,
  // 出错时渲染的组件
  error: ErrorComp,
  // 渲染加载中组件前的等待时间。默认：200ms。
  delay: 200,
  // 最长等待时间。超出此时间则渲染错误组件。默认：Infinity
  timeout: 3000
})
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
      path:'/asyncComp',
      name:'AsyncComp',
      component:AsyncComp
    },
    {
      path:'/LoadingComp',
      name:'LoadingComp',
      component:LoadingComp,
    },
    {
      path:'/page',
      name:'page',
      component:vuexpage,
    },
    {
      path:'/product',
      name:'product',
      component:product,
    }
  ]
})
